-
Notifications
You must be signed in to change notification settings - Fork 904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Unify logging #146
refactor: Unify logging #146
Conversation
console.log(` Open ${relativeXcodeProjectPath} in Xcode`); | ||
console.log(' Hit the Run button'); | ||
logger.info(chalk.white.bold('To run your app on iOS:')); | ||
logger.info(` cd ${absoluteProjectDir}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.info
will prepend INFO
to the message, we don't want it to be here. Can you fold it down to a single logger.info
call with a nice template string inside?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
packages/cli/src/logIOS/logIOS.js
Outdated
@@ -37,7 +38,7 @@ async function logIOS() { | |||
|
|||
const device = findAvailableDevice(devices); | |||
if (device === undefined) { | |||
console.log(chalk.red('No active iOS device found')); | |||
logger.info(chalk.red('No active iOS device found')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.info(chalk.red('No active iOS device found')); | |
logger.error('No active iOS device found'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -33,7 +34,7 @@ function checkAndroid(root) { | |||
*/ | |||
function runAndroid(argv: Array<string>, config: ContextT, args: Object) { | |||
if (!checkAndroid(args.root)) { | |||
console.log( | |||
logger.info( | |||
chalk.red( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be logger.error
without chalk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
} else if (result === 'unrecognized') { | ||
console.warn( | ||
logger.warn( | ||
chalk.yellow('JS server not recognized, continuing with build...') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chalk.yellow('JS server not recognized, continuing with build...') | |
'JS server not recognized, continuing with build...' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this (and similar) still need to be addressed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Should we change the type to accept arrays or actually split the parameter? |
@@ -47,14 +48,14 @@ function runAndroid(argv: Array<string>, config: ContextT, args: Object) { | |||
|
|||
return isPackagerRunning(args.port).then(result => { | |||
if (result === 'running') { | |||
console.log(chalk.bold('JS server already running.')); | |||
logger.info(chalk.bold('JS server already running.')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.info(chalk.bold('JS server already running.')); | |
logger.info('JS server already running.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -101,7 +102,7 @@ function buildAndRun(args) { | |||
adbPath | |||
); | |||
} | |||
console.log(chalk.red('Argument missing for parameter --deviceId')); | |||
logger.info(chalk.red('Argument missing for parameter --deviceId')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.info(chalk.red('Argument missing for parameter --deviceId')); | |
logger.error('Argument missing for parameter --deviceId'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
chalk.yellow('JS server not recognized, continuing with build...') | ||
); | ||
} else { | ||
// result == 'not_running' | ||
console.log(chalk.bold('Starting JS server...')); | ||
logger.info(chalk.bold('Starting JS server...')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.info(chalk.bold('Starting JS server...')); | |
logger.info('Starting JS server...'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thymikee remove all chalk.bold
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
console.log(devices); | ||
logger.info(`Could not find device with the id: "${args.deviceId}".`); | ||
logger.info('Choose one of the following:'); | ||
logger.info(devices); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please fold it into single logger.error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
} | ||
} else { | ||
console.log('No Android devices connected.'); | ||
logger.info('No Android devices connected.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.info('No Android devices connected.'); | |
logger.error('No Android devices connected.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left a bunch of suggestions in certain places, but they hold true for all the code here. One of the reason we use logger
is to get rid of extra chalk
styles as they should be controlled uniformly by the logger, so please remove those. Also there are places where error
is more appropriate than info
– I mark some of them but please review the rest of the diff as well
just spread the devices: logger.info(...devices); |
error or warn? @thymikee |
I'd go with regular |
return; | ||
} | ||
hasWarned = true; | ||
console.warn( | ||
logger.warn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't want logger in debugger-ui
because it runs in a browser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last few bits, and we're good to merge it :)
packages/cli/src/runIOS/runIOS.js
Outdated
logger.info(''); | ||
logger.info('** INSTALLATION FAILED **'); | ||
logger.info('Make sure you have ios-deploy installed globally.'); | ||
logger.info('(e.g "npm install -g ios-deploy")'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we fold this?
@@ -23,13 +23,13 @@ function tryRunAdbReverse(packagerPort: number | string, device: string) { | |||
adbArgs.unshift('-s', device); | |||
} | |||
|
|||
console.log(chalk.bold(`Running ${adbPath} ${adbArgs.join(' ')}`)); | |||
logger.info(chalk.bold(`Running ${adbPath} ${adbArgs.join(' ')}`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.info(chalk.bold(`Running ${adbPath} ${adbArgs.join(' ')}`)); | |
logger.info(`Running ${adbPath} ${adbArgs.join(' ')}`); |
not mine, but it's showing up |
Try rebasing/merging master, as after this PR #144 we dropped |
logger.info('Choose one of the following:'); | ||
printFoundDevices(devices); | ||
logger.error(`Could not find device with the name: "${args.device}". | ||
Choose one of the following:${printFoundDevices(devices)}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printFoundDevices
outputs logs by itself, so this is wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thymikee I changed it to be a list.
There's another place which the output is a list (I think for Android). I changed to be like this to keep some sort of standard. But LMK if I need to revert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, that's good (name could be different now, but there's too much changes to this PR already :D) Thanks for bearing with me!
Summary:
Based on #95, replaced
console.(log|warn|error)
bylogger.(info|warn|error)
.Used regular expressions but everything seems to be working as should.
Test Plan:
All tests are passing, no other change was required.